package com.sx.manage.controller.fund;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sx.manage.controller.base.MBaseController;
import com.sx.manage.service.fund.IMComFundDayProService;
import com.sx.manage.service.fund.IMComFundMonthProService;
import com.sx.manage.service.fund.IMComFundQuarterProService;
import com.sx.manage.servlet.ViewAndModel;
import com.sx.model.manage.mybatis.form.fund.MCompanyFundMonthProfitinfoForm;
import com.sx.model.manage.mybatis.form.fund.MCompanyFundQuarterProfitInfoForm;
import com.sx.model.manage.mybatis.vo.fund.MComFundMonthProVO;
import com.sx.model.manage.mybatis.vo.fund.MComFundQuarterProVO;
import com.sx.model.manage.mybatis.vo.result.ResultListVO;

/**
 * 公司收益
 * 
 * @author lenovo
 *
 */
@Controller
@RequestMapping("/companyProfit")
public class MCompanyProfitController extends MBaseController {
	private Logger _log = LoggerFactory.getLogger(this.getClass());
	// 日收益
	@Resource(name="comFundDayProServiceImpl")
	private IMComFundDayProService comFundDayProServiceImpl;
	// 月收益
	@Resource(name="companyFundMonthProfitServiceImpl")
	private IMComFundMonthProService companyFundMonthProfitServiceImpl;
	// 季度收益 
	@Resource(name="companyFundQuarterProfitServiceImpl")
	private IMComFundQuarterProService companyFundQuarterProfitServiceImpl;
	
	public IMComFundDayProService getComFundDayProServiceImpl() {
		return comFundDayProServiceImpl;
	}
	public void setComFundDayProServiceImpl(
			IMComFundDayProService comFundDayProServiceImpl) {
		this.comFundDayProServiceImpl = comFundDayProServiceImpl;
	}
	public IMComFundMonthProService getCompanyFundMonthProfitServiceImpl() {
		return companyFundMonthProfitServiceImpl;
	}
	public void setCompanyFundMonthProfitServiceImpl(
			IMComFundMonthProService companyFundMonthProfitServiceImpl) {
		this.companyFundMonthProfitServiceImpl = companyFundMonthProfitServiceImpl;
	}
	public IMComFundQuarterProService getCompanyFundQuarterProfitServiceImpl() {
		return companyFundQuarterProfitServiceImpl;
	}
	public void setCompanyFundQuarterProfitServiceImpl(
			IMComFundQuarterProService companyFundQuarterProfitServiceImpl) {
		this.companyFundQuarterProfitServiceImpl = companyFundQuarterProfitServiceImpl;
	}

	/**
	 * 直接收益列表界面
	 */
	@RequestMapping(value = "directIncome")
	public ViewAndModel directIncome() {
		_log.info("直接收益列表界面");
		ViewAndModel model = new ViewAndModel(request,cache);
		model.setViewName("fund/company/directIncome");
		// 界面展开 菜单栏使用
		return model;
	}

	/**
	 * 直接受益月度详细界面
	 */
	@RequestMapping(value = "directMonthDetail/{id}")
	public ViewAndModel directMonthDetail(@PathVariable Long id) {
		ViewAndModel model = new ViewAndModel(request,cache);
		model.setViewName("fund/company/directDetail");
		model.addObject("dataId", id);
		// 界面展开 菜单栏使用
		return model;
	}

	/** 获取用户分页信息 */
	@RequestMapping(value = "directPage")
	@ResponseBody
	public ResultListVO<MComFundQuarterProVO> directPage(MCompanyFundQuarterProfitInfoForm form) {
		// 数据查询
		return this.companyFundQuarterProfitServiceImpl.queryPage(form);
	}
	/** 获取用户分页信息 */
	@RequestMapping(value = "detailPage/{id}")
	@ResponseBody
	public ResultListVO<MComFundMonthProVO> detailPage(@PathVariable Long id,MCompanyFundMonthProfitinfoForm form) {
		//获取季度数据信息
		MComFundQuarterProVO quarterVO = this.companyFundQuarterProfitServiceImpl.queryById( id ).getObjVo();
		 form.setYear( quarterVO.getYear_() );
         form.setQuarter( quarterVO.getQuarter_() );
         form.setChannel( String.valueOf( quarterVO.getCompany_channel_category_id() ) );
         form.setChannel_str( String.valueOf( quarterVO.getCompany_channel_category() ) );
         form.setCompany_id( quarterVO.getCompany_id() );
			/*				  form.set*/
		// 数据查询
         return this.companyFundMonthProfitServiceImpl.queryComFundMonthProPage(form);
	}
	/**
	 * 渠道收益列表界面
	 */
	@RequestMapping(value = "channelIncome")
	public ViewAndModel channelIncome() {
		_log.info("直接收益列表界面");
		ViewAndModel model = new ViewAndModel(request,cache);
		model.setViewName("fund/company/channelIncome");
		// 界面展开 菜单栏使用
		return model;
	}

	/**
	 * 渠道受益月度详细界面
	 */
	@RequestMapping(value = "channelMonthDetail/{id}/{channelStr}")
	public ViewAndModel channelMonthDetail(@PathVariable Long id,@PathVariable String channelStr) {
		ViewAndModel model = new ViewAndModel(request,cache);
		model.setViewName("fund/company/channelDetail");
		model.addObject("dataId", id);
		model.addObject("channelStr", channelStr);
		// 界面展开 菜单栏使用
		return model;
	}
	
	/** 获取用户分页信息 */
	@RequestMapping(value = "channelMonthDetailList/{id}/{channelStr}")
	@ResponseBody
	public ResultListVO<MComFundMonthProVO> channelMonthDetailList(@PathVariable Long id,
			MCompanyFundMonthProfitinfoForm form) {
		//获取季度数据信息
		MComFundQuarterProVO quarterVO = this.companyFundQuarterProfitServiceImpl.queryById( id ).getObjVo();
		                      form.setYear( quarterVO.getYear_() );
		                      form.setQuarter( quarterVO.getQuarter_() );
		                      form.setChannel( String.valueOf( quarterVO.getCompany_channel_category_id() ) );
		                      form.setChannel_str( String.valueOf( quarterVO.getCompany_channel_category() ) );
		// 数据查询
		return this.companyFundMonthProfitServiceImpl.queryComFundMonthProPage(form);
	}
	/** 获取用户分页信息 */
	@RequestMapping(value = "channelPage")
	@ResponseBody
	public ResultListVO<MComFundQuarterProVO> channelPage(MCompanyFundQuarterProfitInfoForm form) {
		// 数据查询
		return this.companyFundQuarterProfitServiceImpl.queryPage( form );
	}
}
